{include file="public/header" /}


<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_promotion_mansong}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <form method="get" name="formSearch">
        <div class="ds-search-form">
            <dl>
                <dt>{$Think.lang.mansong_name}</dt>
                <dd><input type="text" value="{$Request.get.mansong_name}" name="mansong_name" id="mansong_name" class="txt" style="width:100px;"></dd>
            </dl>
            <dl>
                <dt>分类</dt>
                <select name="search_gc_id1" id="search_gc_id1">
                    <option value="">{$Think.lang.ds_please_choose}</option>
                    {notemtpy name="$class_list"}
                    {foreach $class_list as $key => $val}
                    <option value="{$val.gc_id}" {$Request.param.search_gc_id1 == $val.gc_id ? 'selected' : ''}>{$val.gc_name}</option>
                    {/foreach}
                    {/notempty}
                </select>
                <select name="search_gc_id2" id="search_gc_id2">
                    <option value="">{$Think.lang.ds_please_choose}</option>
                </select>
                <select name="search_gc_id3" id="search_gc_id3">
                    <option value="">{$Think.lang.ds_please_choose}</option>
                </select>
            </dl>
<!--            <dl>-->
<!--                <dt>{$Think.lang.ds_store_name}</dt>-->
<!--                <dd><input type="text" value="{$Request.get.store_name}" name="store_name" id="store_name" class="txt" style="width:100px;"></dd>-->
<!--            </dl>-->
            <dl>
                <dt>{$Think.lang.ds_state}</dt>
                <dd>
                    <select name="state">
                        {notempty name="mansong_state_array"}
                        {foreach name="mansong_state_array" item="val"}
                        <option value="{$key}" {eq name="key" value="$Request.get.state"}selected{/eq}>{$val}</option>
                        {/foreach}
                        {/notempty}
                    </select>
                </dd>
            </dl>
            <div class="btn_group">
                <a href="javascript:document.formSearch.submit();" class="btn " title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>
                {if $filtered}
                <a href="{:url('Promotionmansong/index')}" class="btn" title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a>
                {/if}
            </div>
        </div>
    </form>
    <!-- 帮助 -->
<!--    <div class="explanation" id="explanation">-->
<!--        <div class="title" id="checkZoom">-->
<!--            <h4 title="{$Think.lang.ds_explanation_tip}">{$Think.lang.ds_explanation}</h4>-->
<!--            <span id="explanationZoom" title="{$Think.lang.ds_explanation_close}" class="arrow"></span>-->
<!--        </div>-->
<!--        <ul>-->
<!--            <li>{$Think.lang.mansong_list_help1}</li>-->
<!--            <li>{$Think.lang.mansong_list_help2}</li>-->
<!--            <li>{$Think.lang.mansong_list_help3}</li>-->
<!--        </ul>-->
<!--    </div>-->

    
    <!-- 列表 -->
        <table class="ds-default-table">
            <thead>
            <tr class="thead">
                <th class="w24">序号</th>
                <th class="align-left"><span>{$Think.lang.mansong_name}</span></th>
                <th class="align-center" width="300"><span>分类名称</span></th>
<!--                <th class="align-left" width="200"><span>{$Think.lang.ds_store_name}</span></th>-->
                <th class="align-center" width="200"><span>{$Think.lang.ds_start_time}</span></th>
                <th class="align-center" width="200"><span>{$Think.lang.ds_end_time}</span></th>
                <th class="align-center" width="80"><span>{$Think.lang.ds_state}</span></th>
                <th class="align-center" width="200"><span>{$Think.lang.ds_handle}</span></th>
            </tr>
            </thead>
            <tbody id="treet1">
            {notempty name="mansong_list"}
            {foreach name="mansong_list" item="val"}
            <tr class="hover" id="ds_row_{$val.mansong_id}">
                <td>{$val.mansong_id}</td>
<!--                <td><input type="checkbox" class="checkitem" name="mansong_id[]" value="{$val.mansong_id}" /></td>-->
                <td class="align-left"><span>{$val.mansong_name}</span></td>
                <td class="align-left"><span>{$val.class_name}</span></td>
<!--                <td class="align-left"><a-->
<!--                        href="{:url('home/Store/index',['store_id'=>$val.store_id])}"><span>{$val.store_name}</span></a>-->
<!--                    {present name="flippedOwnShopIds[$val.store_id]"}-->
<!--                    <span class="ownshop">[{$Think.lang.ds_ownshop}]</span>-->
<!--                    {/present}-->
<!--                </td>-->
                <td class="align-center"><span>{$val.mansong_starttime|date="Y-m-d H:i:s",###}</span></td>
                <td class="align-center"><span>{$val.mansong_endtime|date="Y-m-d H:i:s",###}</span></td>
                <td class="align-center"><span>{$val.mansong_state_text}</span></td>

                <td class="nowrap align-center">
                    <!-- 详细按钮 -->
                    <a href="javascript:dsLayerOpen('{:url('Promotionmansong/mansong_detail',['mansong_id'=>$val.mansong_id])}','{$val.mansong_name}查看','800px','600px')" class="dsui-btn-view"><i class="iconfont"></i>查看</a>
                    <a href="{:url('Promotionmansong/mansong_edit','mansong_id='.$val.mansong_id)}" class="dsui-btn-edit"><i class="iconfont"></i>编辑</a>
<!--                     <a href="javascript:dsLayerOpen('{:url('Promotionmansong/mansong_stration',['mansong_id'=>$val.mansong_id])}','{$val.mansong_name}管理','800px','600px')" class="dsui-btn-edit"><i class="iconfont"></i>管理</a> -->
                    {if $val.editable}
<!--                    <a href="javascript:dsLayerConfirm('{:url('Promotionmansong/mansong_cancel',['mansong_id'=>$val.mansong_id])}','{$Think.lang.ds_ensure_cancel}')" class="dsui-btn-edit"><i class="iconfont"></i>{$Think.lang.ds_cancel}</a>-->
                    {/if}
                    <a href="javascript:dsLayerConfirm('{:url('Promotionmansong/mansong_del',['mansong_id'=>$val.mansong_id])}','{$Think.lang.ds_ensure_del}',{$val.mansong_id})" class="dsui-btn-del"><i class="iconfont"></i>{$Think.lang.ds_del}</a>
                    <!--
                    <?php if($val['mansong_state']==1){ ?>
                    <a href="javascript:void(0);"
                       onclick="ds_ajaxget_confirm('{:url('Promotionmansong/status',['id'=>$val.mansong_id,'status'=>2])}','确定要关闭吗？');"
                       class="dsui-btn-edit"><i class="iconfont"></i>关闭</a>
                    <?php }else{ ?>
                    <a href="javascript:void(0);"
                       onclick="ds_ajaxget_confirm('{:url('Promotionmansong/status',['id'=>$val.mansong_id,'status'=>1])}','确定要开启吗？');"
                       class="dsui-btn-edit"><i class="iconfont"></i>开启</a>
                    <?php }?>
                    -->
                </td>
            </tr>
            {/foreach}
            {else}
            <tr class="no_data">
                <td colspan="16">{$Think.lang.ds_no_record}</td>
            </tr>
            {/notempty}
            </tbody>
            <tfoot>
            {notempty name="mansong_list"}
<!--            <tr class="tfoot">-->
<!--                <td><input type="checkbox" class="checkall" id="checkallBottom"></td>-->
<!--                <td colspan="16"><label for="checkallBottom">{$Think.lang.ds_select_all}</label>-->
<!--                    &nbsp;&nbsp;<a href="JavaScript:void(0);" class="btn btn-small" onclick="submit_delete_batch()"><span>{$Think.lang.ds_del}</span></a>-->
<!--                </td>-->
<!--            </tr>-->
            {/notempty}
        </tfoot>
        </table>
        {$show_page}

</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>

<script src="{$Think.ADMIN_SITE_ROOT}/js/question.js"></script>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript">
    function submit_delete(ids_str) {
        _uri = ADMINSITEURL + "/Promotionmansong/mansong_del.html?mansong_id=" + ids_str;
        dsLayerConfirm(_uri, '{$Think.lang.ds_ensure_del}');
    }
            function getGcId1(gc_id1, select_id)
    {
        var select_od = select_id;
        $.ajax({
            type : "GET",
            contentType: "application/json;charset=UTF-8",
            url : ADMINSITEURL+"/Question/getClass.html?gc_id=" + gc_id1,
            success : function(result) {
                result = JSON.parse( result );
                var html = '<option value="">选择分类</option>';
                for(var i=0;i<result.length;i++){
                    if (result[i].gc_id == select_id) {
                        html += '<option selected value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    } else {
                        html += '<option value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    }
                }
                $('#search_gc_id2').html(html)
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }

    function getGcId2(gc_id1, select_id)
    {
        $.ajax({
            type : "GET",
            contentType: "application/json;charset=UTF-8",
            url : ADMINSITEURL+"/Question/getClass.html?gc_id=" + gc_id1,
            success : function(result) {
                result = JSON.parse( result );
                var html = '<option value="">选择分类</option>';
                for(var i=0;i<result.length;i++){
                    if (result[i].gc_id == select_id) {
                        html += '<option selected value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    } else {
                        html += '<option value="'+ result[i].gc_id +'">'+ result[i].gc_name +'</option>'
                    }
                }
                $('#search_gc_id3').html(html)
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }
    //获取下级分类
    $('#search_gc_id1').on('change',function () {
        var gc_id1 = $(this).val();
        getGcId1(gc_id1)
    })

    $('#search_gc_id2').on('change',function () {
        var gc_id2 = $(this).val();
        getGcId2(gc_id2)
    })
</script>
{if $Request.param.search_gc_id1}
<script>

    // 编辑初始化，处理分类选中的问题
        var gc_id1 = '{$Request.param.search_gc_id1}';
        var gc_id2 = '{$Request.param.search_gc_id2}';
        var gc_id3 = '{$Request.param.search_gc_id3}';
        getGcId1(gc_id1, gc_id2)
        getGcId2(gc_id2, gc_id3)
</script>
{/if}
</script>